package cn.xfdzx.android.apps.shop.adapter;

import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;

import java.util.List;

import cn.xfdzx.android.apps.shop.R;
import cn.xfdzx.android.apps.shop.bean.OrderProcessBeen;
import cn.xfdzx.android.apps.shop.util.EmptyUtil;
import cn.xfdzx.android.apps.shop.util.ImageGlideUtil;

/**
 * Creator: zf.
 * Date: 2020/7/27.
 * Description:取消订单原因适配器.
 */
public class RefundReasonAdapter extends BaseQuickAdapter<String, BaseViewHolder>  {
    private OnItemOnClickListener onItemOnClickListener;
    private List<String> cartInfo;//商品列表 = new ArrayList<>();//商品列表
    private int position = -1;
    public RefundReasonAdapter(@Nullable List<String> data) {
        super(R.layout.item_cancel_order_why, data);
    }

    @Override
    public void setData(int index, @NonNull String data) {
        super.setData(index, data);
    }


    @Override
    protected void convert(final BaseViewHolder viewHolder, final String date) {
        TextView tv_why = viewHolder.getView(R.id.tv_why);
        tv_why.setText(date);
        ImageView imageView = viewHolder.getView(R.id.iv_why_dui);
        if (position == viewHolder.getLayoutPosition()){
            imageView.setImageResource(R.drawable.icon_select_address_green);
        }else {
            imageView.setImageResource(R.drawable.d99999_oval);
        }
        viewHolder.itemView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
              //
                onItemOnClickListener.onItemClick(viewHolder.getLayoutPosition(),date);
            }
        });
    }
    public void clearDatas(){
        mData.clear();
        notifyDataSetChanged();
    }
    public void refreshDatas(List<String> list){
        this.cartInfo = list;
        super.replaceData(list);
    }

    public void setItemState(int position){
        this.position = position;
        notifyDataSetChanged();
    }

    public void setItemListener(OnItemOnClickListener listener){
        this.onItemOnClickListener = listener;
    }

    public interface OnItemOnClickListener {
        void onItemClick(int position, String date);
    }

}
